home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Games / MAME / src / drivers / mpatrol.c < prev    next >
C/C++ Source or Header  |  2000-04-23  |  21KB  |  520 lines

  1. /***************************************************************************
  2.  
  3. Moon Patrol memory map (preliminary)
  4.  
  5. driver by Nicola Salmoria
  6.  
  7. 0000-3fff ROM
  8. 8000-83ff Video RAM
  9. 8400-87ff Color RAM
  10. e000-e7ff RAM
  11.  
  12.  
  13. read:
  14. 8800      protection
  15. d000      IN0
  16. d001      IN1
  17. d002      IN2
  18. d003      DSW1
  19. d004      DSW2
  20.  
  21. write:
  22. c820-c87f sprites
  23. c8a0-c8ff sprites
  24. d000      sound command
  25. d001      flip screen
  26.  
  27. I/O ports
  28. write:
  29. 10-1f     scroll registers
  30. 40        background #1 x position
  31. 60        background #1 y position
  32. 80        background #2 x position
  33. a0        background #2 y position
  34. c0        background control?
  35.  
  36. ***************************************************************************/
  37.  
  38. #include "driver.h"
  39. #include "sndhrdw/irem.h"
  40. #include "vidhrdw/generic.h"
  41. #include "cpu/z80/z80.h"
  42.  
  43.  
  44.  
  45. WRITE_HANDLER( mpatrol_scroll_w );
  46. WRITE_HANDLER( mpatrol_bg1xpos_w );
  47. WRITE_HANDLER( mpatrol_bg1ypos_w );
  48. WRITE_HANDLER( mpatrol_bg2xpos_w );
  49. WRITE_HANDLER( mpatrol_bg2ypos_w );
  50. WRITE_HANDLER( mpatrol_bgcontrol_w );
  51. WRITE_HANDLER( mpatrol_flipscreen_w );
  52. int mpatrol_vh_start(void);
  53. void mpatrol_vh_stop(void);
  54. void mpatrol_vh_convert_color_prom(unsigned char *palette, unsigned short *colortable,const unsigned char *color_prom);
  55. void mpatrol_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh);
  56.  
  57. READ_HANDLER( mpatrol_input_port_3_r );
  58.  
  59.  
  60.  
  61. /* this looks like some kind of protection. The game does strange things */
  62. /* if a read from this address doesn't return the value it expects. */
  63. READ_HANDLER( mpatrol_protection_r )
  64. {
  65. //logerror("%04x: read protection\n",cpu_get_pc());
  66.     return cpu_get_reg(Z80_DE) & 0xff;
  67. }
  68.  
  69.  
  70.  
  71. static struct MemoryReadAddress readmem[] =
  72. {
  73.     { 0x0000, 0x3fff, MRA_ROM },
  74.     { 0x8000, 0x87ff, MRA_RAM },
  75.     { 0x8800, 0x8800, mpatrol_protection_r },
  76.     { 0xd000, 0xd000, input_port_0_r },          /* IN0 */
  77.     { 0xd001, 0xd001, input_port_1_r },          /* IN1 */
  78.     { 0xd002, 0xd002, input_port_2_r },          /* IN2 */
  79.     { 0xd003, 0xd003, mpatrol_input_port_3_r },  /* DSW1 */
  80.     { 0xd004, 0xd004, input_port_4_r },          /* DSW2 */
  81.     { 0xe000, 0xe7ff, MRA_RAM },
  82.     { -1 }  /* end of table */
  83. };
  84.  
  85. static struct MemoryWriteAddress writemem[] =
  86. {
  87.     { 0x0000, 0x7fff, MWA_ROM },
  88.     { 0x8000, 0x83ff, videoram_w, &videoram, &videoram_size },
  89.     { 0x8400, 0x87ff, colorram_w, &colorram },
  90.     { 0xc820, 0xc87f, MWA_RAM, &spriteram, &spriteram_size },
  91.     { 0xc8a0, 0xc8ff, MWA_RAM, &spriteram_2 },
  92.     { 0xd000, 0xd000, irem_sound_cmd_w },
  93.     { 0xd001, 0xd001, mpatrol_flipscreen_w },    /* + coin counters */
  94.     { 0xe000, 0xe7ff, MWA_RAM },
  95.     { -1 }  /* end of table */
  96. };
  97.  
  98.  
  99.  
  100. static struct IOWritePort writeport[] =
  101. {
  102.     { 0x10, 0x1f, mpatrol_scroll_w },
  103.     { 0x40, 0x40, mpatrol_bg1xpos_w },
  104.     { 0x60, 0x60, mpatrol_bg1ypos_w },
  105.     { 0x80, 0x80, mpatrol_bg2xpos_w },
  106.     { 0xa0, 0xa0, mpatrol_bg2ypos_w },
  107.     { 0xc0, 0xc0, mpatrol_bgcontrol_w },
  108.     { -1 }  /* end of table */
  109. };
  110.  
  111.  
  112.  
  113. INPUT_PORTS_START( mpatrol )
  114.     PORT_START      /* IN0 */
  115.     PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_START1 )
  116.     PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_START2 )
  117.     /* coin input must be active for ? frames to be consistently recognized */
  118.     PORT_BIT_IMPULSE( 0x04, IP_ACTIVE_LOW, IPT_COIN3, 17 )
  119.     PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_COIN1 )
  120.     PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN )
  121.     PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN )
  122.     PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
  123.     PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
  124.  
  125.     PORT_START      /* IN1 */
  126.     PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_2WAY )
  127.     PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_2WAY )
  128.     PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )
  129.     PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN )
  130.     PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN )
  131.     PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 )
  132.     PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
  133.     PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON1 )
  134.  
  135.     PORT_START      /* IN2 */
  136.     PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_2WAY | IPF_COCKTAIL )
  137.     PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_2WAY | IPF_COCKTAIL )
  138.     PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )
  139.     PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN )
  140.     PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_COIN2 )
  141.     PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_COCKTAIL )
  142.     PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
  143.     PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_COCKTAIL )
  144.  
  145.     PORT_START      /* DSW0 */
  146.     PORT_DIPNAME( 0x03, 0x02, DEF_STR( Lives ) )
  147.     PORT_DIPSETTING(    0x00, "1" )
  148.     PORT_DIPSETTING(    0x01, "2" )
  149.     PORT_DIPSETTING(    0x02, "3" )
  150.     PORT_DIPSETTING(    0x03, "5" )
  151.     PORT_DIPNAME( 0x0c, 0x0c, DEF_STR( Bonus_Life ) )
  152.     PORT_DIPSETTING(    0x0c, "10000 30000 50000" )
  153.     PORT_DIPSETTING(    0x08, "20000 40000 60000" )
  154.     PORT_DIPSETTING(    0x04, "10000" )
  155.     PORT_DIPSETTING(    0x00, "None" )
  156.     PORT_BIT( 0xf0, IP_ACTIVE_HIGH, IPT_UNUSED )  /* Gets filled in based on the coin mode */
  157.  
  158.     PORT_START      /* DSW1 */
  159.     PORT_DIPNAME( 0x01, 0x01, DEF_STR( Flip_Screen ) )
  160.     PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
  161.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  162.     PORT_DIPNAME( 0x02, 0x00, DEF_STR( Cabinet ) )
  163.     PORT_DIPSETTING(    0x00, DEF_STR( Upright ) )
  164.     PORT_DIPSETTING(    0x02, DEF_STR( Cocktail ) )
  165.     PORT_DIPNAME( 0x04, 0x04, "Coin Mode" )
  166.     PORT_DIPSETTING(    0x04, "Mode 1" )
  167.     PORT_DIPSETTING(    0x00, "Mode 2" )
  168.     PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unknown ) )
  169.     PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
  170.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  171.     /* In stop mode, press 2 to stop and 1 to restart */
  172.     PORT_BITX   ( 0x10, 0x10, IPT_DIPSWITCH_NAME | IPF_CHEAT, "Stop Mode", IP_KEY_NONE, IP_JOY_NONE )
  173.     PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
  174.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  175.     PORT_BITX(    0x20, 0x20, IPT_DIPSWITCH_NAME | IPF_CHEAT, "Sector Selection", IP_KEY_NONE, IP_JOY_NONE )
  176.     PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
  177.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  178.     PORT_BITX(    0x40, 0x40, IPT_DIPSWITCH_NAME | IPF_CHEAT, "Invulnerability", IP_KEY_NONE, IP_JOY_NONE )
  179.     PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
  180.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  181.     PORT_SERVICE( 0x80, IP_ACTIVE_LOW )
  182.  
  183.     /* Fake port to support the two different coin modes */
  184.     PORT_START
  185.     PORT_DIPNAME( 0x0f, 0x0f, "Coinage Mode 1" )   /* mapped on coin mode 1 */
  186.     PORT_DIPSETTING(    0x09, DEF_STR( 7C_1C ) )
  187.     PORT_DIPSETTING(    0x0a, DEF_STR( 6C_1C ) )
  188.     PORT_DIPSETTING(    0x0b, DEF_STR( 5C_1C ) )
  189.     PORT_DIPSETTING(    0x0c, DEF_STR( 4C_1C ) )
  190.     PORT_DIPSETTING(    0x0d, DEF_STR( 3C_1C ) )
  191.     PORT_DIPSETTING(    0x0e, DEF_STR( 2C_1C ) )
  192.     PORT_DIPSETTING(    0x0f, DEF_STR( 1C_1C ) )
  193.     PORT_DIPSETTING(    0x07, DEF_STR( 1C_2C ) )
  194.     PORT_DIPSETTING(    0x06, DEF_STR( 1C_3C ) )
  195.     PORT_DIPSETTING(    0x05, DEF_STR( 1C_4C ) )
  196.     PORT_DIPSETTING(    0x04, DEF_STR( 1C_5C ) )
  197.     PORT_DIPSETTING(    0x03, DEF_STR( 1C_6C ) )
  198.     PORT_DIPSETTING(    0x02, DEF_STR( 1C_7C ) )
  199.     PORT_DIPSETTING(    0x01, DEF_STR( 1C_8C ) )
  200.     PORT_DIPSETTING(    0x00, DEF_STR( Free_Play ) )
  201.      PORT_DIPNAME( 0x30, 0x30, "Coin A  Mode 2" )   /* mapped on coin mode 2 */
  202.     PORT_DIPSETTING(    0x10, DEF_STR( 3C_1C ) )
  203.     PORT_DIPSETTING(    0x20, DEF_STR( 2C_1C ) )
  204.     PORT_DIPSETTING(    0x30, DEF_STR( 1C_1C ) )
  205.     PORT_DIPSETTING(    0x00, DEF_STR( Free_Play ) )
  206.     PORT_DIPNAME( 0xc0, 0xc0, "Coin B  Mode 2" )
  207.     PORT_DIPSETTING(    0xc0, DEF_STR( 1C_2C ) )
  208.     PORT_DIPSETTING(    0x80, DEF_STR( 1C_3C ) )
  209.     PORT_DIPSETTING(    0x40, DEF_STR( 1C_5C ) )
  210.     PORT_DIPSETTING(    0x00, DEF_STR( 1C_6C ) )
  211. INPUT_PORTS_END
  212.  
  213. /* Identical to mpatrol, the only difference is the number of lives */
  214. INPUT_PORTS_START( mpatrolw )
  215.     PORT_START      /* IN0 */
  216.     PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_START1 )
  217.     PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_START2 )
  218. /* coin input must be active for ? frames to be consistently recognized */
  219.     PORT_BIT_IMPULSE( 0x04, IP_ACTIVE_LOW, IPT_COIN3, 17 )
  220.     PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_COIN1 )
  221.     PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN )
  222.     PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN )
  223.     PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
  224.     PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
  225.  
  226.     PORT_START      /* IN1 */
  227.     PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_2WAY )
  228.     PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_2WAY )
  229.     PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )
  230.     PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN )
  231.     PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN )
  232.     PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 )
  233.     PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
  234.     PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON1 )
  235.  
  236.     PORT_START      /* IN2 */
  237.     PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_2WAY | IPF_COCKTAIL )
  238.     PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_2WAY | IPF_COCKTAIL )
  239.     PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )
  240.     PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN )
  241.     PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_COIN2 )
  242.     PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_COCKTAIL )
  243.     PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
  244.     PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_COCKTAIL )
  245.  
  246.     PORT_START      /* DSW0 */
  247.     PORT_DIPNAME( 0x03, 0x01, DEF_STR( Lives ) )
  248.     PORT_DIPSETTING(    0x00, "2" )
  249.     PORT_DIPSETTING(    0x01, "3" )
  250.     PORT_DIPSETTING(    0x02, "4" )
  251.     PORT_DIPSETTING(    0x03, "5" )
  252.     PORT_DIPNAME( 0x0c, 0x0c, DEF_STR( Bonus_Life ) )
  253.     PORT_DIPSETTING(    0x0c, "10000 30000 50000" )
  254.     PORT_DIPSETTING(    0x08, "20000 40000 60000" )
  255.     PORT_DIPSETTING(    0x04, "10000" )
  256.     PORT_DIPSETTING(    0x00, "None" )
  257.     PORT_BIT( 0xf0, IP_ACTIVE_HIGH, IPT_UNUSED )  /* Gets filled in based on the coin mode */
  258.  
  259.     PORT_START      /* DSW1 */
  260.     PORT_DIPNAME( 0x01, 0x01, DEF_STR( Flip_Screen ) )
  261.     PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
  262.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  263.     PORT_DIPNAME( 0x02, 0x00, DEF_STR( Cabinet ) )
  264.     PORT_DIPSETTING(    0x00, DEF_STR( Upright ) )
  265.     PORT_DIPSETTING(    0x02, DEF_STR( Cocktail ) )
  266.     PORT_DIPNAME( 0x04, 0x04, "Coin Mode" )
  267.     PORT_DIPSETTING(    0x04, "Mode 1" )
  268.     PORT_DIPSETTING(    0x00, "Mode 2" )
  269.     PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unknown ) )
  270.     PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
  271.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  272.     /* In stop mode, press 2 to stop and 1 to restart */
  273.     PORT_BITX   ( 0x10, 0x10, IPT_DIPSWITCH_NAME | IPF_CHEAT, "Stop Mode", IP_KEY_NONE, IP_JOY_NONE )
  274.     PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
  275.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  276.     PORT_BITX(    0x20, 0x20, IPT_DIPSWITCH_NAME | IPF_CHEAT, "Sector Selection", IP_KEY_NONE, IP_JOY_NONE )
  277.     PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
  278.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  279.     PORT_BITX(    0x40, 0x40, IPT_DIPSWITCH_NAME | IPF_CHEAT, "Invulnerability", IP_KEY_NONE, IP_JOY_NONE )
  280.     PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
  281.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  282.     PORT_SERVICE( 0x80, IP_ACTIVE_LOW )
  283.  
  284.     /* Fake port to support the two different coin modes */
  285.     PORT_START
  286.     PORT_DIPNAME( 0x0f, 0x0f, "Coinage Mode 1" )   /* mapped on coin mode 1 */
  287.     PORT_DIPSETTING(    0x09, DEF_STR( 7C_1C ) )
  288.     PORT_DIPSETTING(    0x0a, DEF_STR( 6C_1C ) )
  289.     PORT_DIPSETTING(    0x0b, DEF_STR( 5C_1C ) )
  290.     PORT_DIPSETTING(    0x0c, DEF_STR( 4C_1C ) )
  291.     PORT_DIPSETTING(    0x0d, DEF_STR( 3C_1C ) )
  292.     PORT_DIPSETTING(    0x0e, DEF_STR( 2C_1C ) )
  293.     PORT_DIPSETTING(    0x0f, DEF_STR( 1C_1C ) )
  294.     PORT_DIPSETTING(    0x07, DEF_STR( 1C_2C ) )
  295.     PORT_DIPSETTING(    0x06, DEF_STR( 1C_3C ) )
  296.     PORT_DIPSETTING(    0x05, DEF_STR( 1C_4C ) )
  297.     PORT_DIPSETTING(    0x04, DEF_STR( 1C_5C ) )
  298.     PORT_DIPSETTING(    0x03, DEF_STR( 1C_6C ) )
  299.     PORT_DIPSETTING(    0x02, DEF_STR( 1C_7C ) )
  300.     PORT_DIPSETTING(    0x01, DEF_STR( 1C_8C ) )
  301.     PORT_DIPSETTING(    0x00, DEF_STR( Free_Play ) )
  302.      PORT_DIPNAME( 0x30, 0x30, "Coin A  Mode 2" )   /* mapped on coin mode 2 */
  303.     PORT_DIPSETTING(    0x10, DEF_STR( 3C_1C ) )
  304.     PORT_DIPSETTING(    0x20, DEF_STR( 2C_1C ) )
  305.     PORT_DIPSETTING(    0x30, DEF_STR( 1C_1C ) )
  306.     PORT_DIPSETTING(    0x00, DEF_STR( Free_Play ) )
  307.     PORT_DIPNAME( 0xc0, 0xc0, "Coin B  Mode 2" )
  308.     PORT_DIPSETTING(    0xc0, DEF_STR( 1C_2C ) )
  309.     PORT_DIPSETTING(    0x80, DEF_STR( 1C_3C ) )
  310.     PORT_DIPSETTING(    0x40, DEF_STR( 1C_5C ) )
  311.     PORT_DIPSETTING(    0x00, DEF_STR( 1C_6C ) )
  312. INPUT_PORTS_END
  313.  
  314.  
  315.  
  316. static struct GfxLayout charlayout =
  317. {
  318.     8,8,    /* 8*8 characters */
  319.     512,    /* 512 characters */
  320.     2,      /* 2 bits per pixel */
  321.     { 0, 512*8*8 }, /* the two bitplanes are separated */
  322.     { 0, 1, 2, 3, 4, 5, 6, 7 },
  323.     { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 },
  324.     8*8     /* every char takes 8 consecutive bytes */
  325. };
  326. static struct GfxLayout spritelayout =
  327. {
  328.     16,16,  /* 16*16 sprites */
  329.     128,    /* 128 sprites */
  330.     2,      /* 2 bits per pixel */
  331.     { 0, 128*16*16 },       /* the two bitplanes are separated */
  332.     { 0, 1, 2, 3, 4, 5, 6, 7,
  333.             16*8+0, 16*8+1, 16*8+2, 16*8+3, 16*8+4, 16*8+5, 16*8+6, 16*8+7 },
  334.     { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8,
  335.             8*8, 9*8, 10*8, 11*8, 12*8, 13*8, 14*8, 15*8 },
  336.     32*8    /* every sprite takes 32 consecutive bytes */
  337. };
  338. static struct GfxLayout bgcharlayout =
  339. {
  340.     32,32,  /* 32*32 characters (actually, it is just 1 big 256x64 image) */
  341.     8,      /* 8 characters */
  342.     2,      /* 2 bits per pixel */
  343.     { 4, 0 },       /* the two bitplanes for 4 pixels are packed into one byte */
  344.     { 0, 1, 2, 3, 8+0, 8+1, 8+2, 8+3, 2*8+0, 2*8+1, 2*8+2, 2*8+3, 3*8+0, 3*8+1, 3*8+2, 3*8+3,
  345.             4*8+0, 4*8+1, 4*8+2, 4*8+3, 5*8+0, 5*8+1, 5*8+2, 5*8+3, 6*8+0, 6*8+1, 6*8+2, 6*8+3, 7*8+0, 7*8+1, 7*8+2, 7*8+3 },
  346.     { 0*512, 1*512, 2*512, 3*512, 4*512, 5*512, 6*512, 7*512, 8*512, 9*512, 10*512, 11*512, 12*512, 13*512, 14*512, 15*512,
  347.             16*512, 17*512, 18*512, 19*512, 20*512, 21*512, 22*512, 23*512, 24*512, 25*512, 26*512, 27*512, 28*512, 29*512, 30*512, 31*512 },
  348.     8*8
  349. };
  350.  
  351.  
  352.  
  353. static struct GfxDecodeInfo gfxdecodeinfo[] =
  354. {
  355.     { REGION_GFX1, 0x0000, &charlayout,               0, 64 },
  356.     { REGION_GFX2, 0x0000, &spritelayout,          64*4, 16 },
  357.     { REGION_GFX3, 0x0000, &bgcharlayout, 64*4+16*4+0*4,  1 },    /* top half */
  358.     { REGION_GFX3, 0x0800, &bgcharlayout, 64*4+16*4+0*4,  1 },    /* bottom half */
  359.     { REGION_GFX4, 0x0000, &bgcharlayout, 64*4+16*4+1*4,  1 },    /* top half */
  360.     { REGION_GFX4, 0x0800, &bgcharlayout, 64*4+16*4+1*4,  1 },    /* bottom half */
  361.     { REGION_GFX5, 0x0000, &bgcharlayout, 64*4+16*4+2*4,  1 },    /* top half */
  362.     { REGION_GFX5, 0x0800, &bgcharlayout, 64*4+16*4+2*4,  1 },    /* bottom half */
  363.     { -1 } /* end of array */
  364. };
  365.  
  366.  
  367.  
  368. static struct MachineDriver machine_driver_mpatrol =
  369. {
  370.     /* basic machine hardware */
  371.     {
  372.         {
  373.             CPU_Z80,
  374.             3072000,        /* 3.072 Mhz ? */
  375.             readmem,writemem,0,writeport,
  376.             interrupt,1
  377.         },
  378.         IREM_AUDIO_CPU
  379.     },
  380.     57, 1790,    /* accurate frequency, measured on a real board, is 56.75Hz. */
  381.                 /* the Lode Runner manual (similar but different hardware) */
  382.                 /* talks about 55Hz and 1790ms vblank duration. */
  383.     1,    /* 1 CPU slice per frame - interleaving is forced when a sound command is written */
  384.     0,
  385.  
  386.     /* video hardware */
  387.     32*8, 32*8, { 1*8, 31*8-1, 1*8, 32*8-1 },
  388.     gfxdecodeinfo,
  389.     128+32+32,64*4+16*4+3*4,
  390.     mpatrol_vh_convert_color_prom,
  391.  
  392.     VIDEO_TYPE_RASTER,
  393.     0,
  394.     mpatrol_vh_start,
  395.     mpatrol_vh_stop,
  396.     mpatrol_vh_screenrefresh,
  397.  
  398.     /* sound hardware */
  399.     0,0,0,0,
  400.     {
  401.         IREM_AUDIO
  402.     }
  403. };
  404.  
  405.  
  406.  
  407. /***************************************************************************
  408.  
  409.   Game driver(s)
  410.  
  411. ***************************************************************************/
  412.  
  413. ROM_START( mpatrol )
  414.     ROM_REGION( 0x10000, REGION_CPU1 )     /* 64k for code */
  415.     ROM_LOAD( "mp-a.3m",      0x0000, 0x1000, 0x5873a860 )
  416.     ROM_LOAD( "mp-a.3l",      0x1000, 0x1000, 0xf4b85974 )
  417.     ROM_LOAD( "mp-a.3k",      0x2000, 0x1000, 0x2e1a598c )
  418.     ROM_LOAD( "mp-a.3j",      0x3000, 0x1000, 0xdd05b587 )
  419.  
  420.     ROM_REGION( 0x10000, REGION_CPU2 )     /* 64k for code */
  421.     ROM_LOAD( "mp-snd.1a",    0xf000, 0x1000, 0x561d3108 )
  422.  
  423.     ROM_REGION( 0x2000, REGION_GFX1 | REGIONFLAG_DISPOSE )
  424.     ROM_LOAD( "mp-e.3e",      0x0000, 0x1000, 0xe3ee7f75 )       /* chars */
  425.     ROM_LOAD( "mp-e.3f",      0x1000, 0x1000, 0xcca6d023 )
  426.  
  427.     ROM_REGION( 0x2000, REGION_GFX2 | REGIONFLAG_DISPOSE )
  428.     ROM_LOAD( "mp-b.3m",      0x0000, 0x1000, 0x707ace5e )       /* sprites */
  429.     ROM_LOAD( "mp-b.3n",      0x1000, 0x1000, 0x9b72133a )
  430.  
  431.     ROM_REGION( 0x1000, REGION_GFX3 | REGIONFLAG_DISPOSE )
  432.     ROM_LOAD( "mp-e.3l",      0x0000, 0x1000, 0xc46a7f72 )       /* background graphics */
  433.  
  434.     ROM_REGION( 0x1000, REGION_GFX4 | REGIONFLAG_DISPOSE )
  435.     ROM_LOAD( "mp-e.3k",      0x0000, 0x1000, 0xc7aa1fb0 )
  436.  
  437.     ROM_REGION( 0x1000, REGION_GFX5 | REGIONFLAG_DISPOSE )
  438.     ROM_LOAD( "mp-e.3h",      0x0000, 0x1000, 0xa0919392 )
  439.  
  440.     ROM_REGION( 0x0240, REGION_PROMS )
  441.     ROM_LOAD( "2a",           0x0000, 0x0100, 0x0f193a50 ) /* character palette */
  442.     ROM_LOAD( "1m",           0x0100, 0x0020, 0x6a57eff2 ) /* background palette */
  443.     ROM_LOAD( "1c1j",         0x0120, 0x0020, 0x26979b13 ) /* sprite palette */
  444.     ROM_LOAD( "2hx",          0x0140, 0x0100, 0x7ae4cd97 ) /* sprite lookup table */
  445. ROM_END
  446.  
  447. ROM_START( mpatrolw )
  448.     ROM_REGION( 0x10000, REGION_CPU1 )     /* 64k for code */
  449.     ROM_LOAD( "mpw-a.3m",     0x0000, 0x1000, 0xbaa1a1d4 )
  450.     ROM_LOAD( "mpw-a.3l",     0x1000, 0x1000, 0x52459e51 )
  451.     ROM_LOAD( "mpw-a.3k",     0x2000, 0x1000, 0x9b249fe5 )
  452.     ROM_LOAD( "mpw-a.3j",     0x3000, 0x1000, 0xfee76972 )
  453.  
  454.     ROM_REGION( 0x10000, REGION_CPU2 )     /* 64k for code */
  455.     ROM_LOAD( "mp-snd.1a",    0xf000, 0x1000, 0x561d3108 )
  456.  
  457.     ROM_REGION( 0x2000, REGION_GFX1 | REGIONFLAG_DISPOSE )
  458.     ROM_LOAD( "mpw-e.3e",     0x0000, 0x1000, 0xf56e01fe )       /* chars */
  459.     ROM_LOAD( "mpw-e.3f",     0x1000, 0x1000, 0xcaaba2d9 )
  460.  
  461.     ROM_REGION( 0x2000, REGION_GFX2 | REGIONFLAG_DISPOSE )
  462.     ROM_LOAD( "mp-b.3m",      0x0000, 0x1000, 0x707ace5e )       /* sprites */
  463.     ROM_LOAD( "mp-b.3n",      0x1000, 0x1000, 0x9b72133a )
  464.  
  465.     ROM_REGION( 0x1000, REGION_GFX3 | REGIONFLAG_DISPOSE )
  466.     ROM_LOAD( "mp-e.3l",      0x0000, 0x1000, 0xc46a7f72 )       /* background graphics */
  467.  
  468.     ROM_REGION( 0x1000, REGION_GFX4 | REGIONFLAG_DISPOSE )
  469.     ROM_LOAD( "mp-e.3k",      0x0000, 0x1000, 0xc7aa1fb0 )
  470.  
  471.     ROM_REGION( 0x1000, REGION_GFX5 | REGIONFLAG_DISPOSE )
  472.     ROM_LOAD( "mp-e.3h",      0x0000, 0x1000, 0xa0919392 )
  473.  
  474.     ROM_REGION( 0x0240, REGION_PROMS )
  475.     ROM_LOAD( "2a",           0x0000, 0x0100, 0x0f193a50 ) /* character palette */
  476.     ROM_LOAD( "1m",           0x0100, 0x0020, 0x6a57eff2 ) /* background palette */
  477.     ROM_LOAD( "1c1j",         0x0120, 0x0020, 0x26979b13 ) /* sprite palette */
  478.     ROM_LOAD( "2hx",          0x0140, 0x0100, 0x7ae4cd97 ) /* sprite lookup table */
  479. ROM_END
  480.  
  481. ROM_START( mranger )
  482.     ROM_REGION( 0x10000, REGION_CPU1 )     /* 64k for code */
  483.     ROM_LOAD( "mp-a.3m",      0x0000, 0x1000, 0x5873a860 )
  484.     ROM_LOAD( "mr-a.3l",      0x1000, 0x1000, 0x217dd431 )
  485.     ROM_LOAD( "mr-a.3k",      0x2000, 0x1000, 0x9f0af7b2 )
  486.     ROM_LOAD( "mr-a.3j",      0x3000, 0x1000, 0x7fe8e2cd )
  487.  
  488.     ROM_REGION( 0x10000, REGION_CPU2 )     /* 64k for code */
  489.     ROM_LOAD( "mp-snd.1a",    0xf000, 0x1000, 0x561d3108 )
  490.  
  491.     ROM_REGION( 0x2000, REGION_GFX1 | REGIONFLAG_DISPOSE )
  492.     ROM_LOAD( "mp-e.3e",      0x0000, 0x1000, 0xe3ee7f75 )       /* chars */
  493.     ROM_LOAD( "mp-e.3f",      0x1000, 0x1000, 0xcca6d023 )
  494.  
  495.     ROM_REGION( 0x2000, REGION_GFX2 | REGIONFLAG_DISPOSE )
  496.     ROM_LOAD( "mp-b.3m",      0x0000, 0x1000, 0x707ace5e )       /* sprites */
  497.     ROM_LOAD( "mp-b.3n",      0x1000, 0x1000, 0x9b72133a )
  498.  
  499.     ROM_REGION( 0x1000, REGION_GFX3 | REGIONFLAG_DISPOSE )
  500.     ROM_LOAD( "mp-e.3l",      0x0000, 0x1000, 0xc46a7f72 )       /* background graphics */
  501.  
  502.     ROM_REGION( 0x1000, REGION_GFX4 | REGIONFLAG_DISPOSE )
  503.     ROM_LOAD( "mp-e.3k",      0x0000, 0x1000, 0xc7aa1fb0 )
  504.  
  505.     ROM_REGION( 0x1000, REGION_GFX5 | REGIONFLAG_DISPOSE )
  506.     ROM_LOAD( "mp-e.3h",      0x0000, 0x1000, 0xa0919392 )
  507.  
  508.     ROM_REGION( 0x0240, REGION_PROMS )
  509.     ROM_LOAD( "2a",           0x0000, 0x0100, 0x0f193a50 ) /* character palette */
  510.     ROM_LOAD( "1m",           0x0100, 0x0020, 0x6a57eff2 ) /* background palette */
  511.     ROM_LOAD( "1c1j",         0x0120, 0x0020, 0x26979b13 ) /* sprite palette */
  512.     ROM_LOAD( "2hx",          0x0140, 0x0100, 0x7ae4cd97 ) /* sprite lookup table */
  513. ROM_END
  514.  
  515.  
  516.  
  517. GAME( 1982, mpatrol,  0,       mpatrol, mpatrol,  0, ROT0, "Irem", "Moon Patrol" )
  518. GAME( 1982, mpatrolw, mpatrol, mpatrol, mpatrolw, 0, ROT0, "Irem (Williams license)", "Moon Patrol (Williams)" )
  519. GAME( 1982, mranger,  mpatrol, mpatrol, mpatrol,  0, ROT0, "bootleg", "Moon Ranger" )
  520.